<template>
  <div class="app-container">
    <wise-crud ref="wise-crud" :urls="urls" :fields="fields" :handle="handle" :filters="filters" />
  </div>
</template>
<script>
import WiseCrud from '@/components/Crud/wiseCrud'
export default {
  name: 'WeldingMaterialManage',
  components: { WiseCrud },
  data() {
    return {
      urls: {
        list: '/api/v1/welder-sbtx-second/welding-material-comb/list',
        add: '/api/v1/welder-sbtx-second/welding-material/create',
        show: '/api/v1/welder-sbtx-second/welding-material-comb/show/',
        update: '/api/v1/welder-sbtx-second/welding-material/update/',
        delete: '/api/v1/welder-sbtx-second/welding-material/remove/'
      }
    }
  },
  computed: {
    spaceId() {
      return this.$store.state.project.spaceId
    },
    handle() {
      // if (this.$store.state.user.project) {
      //   return ['add']
      // } else {
      //   return ['add', 'filters']
      // }
      return ['add']
    },
    fields() {
      let arr = [
        { label: '序号', type: 'index', use: ['table'] }
      ]
      if (this.$store.state.user.project) {
        arr.push({
          prop: 'projectId',
          defaultValue: this.$store.state.user.project.id,
          use: ['add', 'edit']
        })
      }
      arr.push(
        {
          label: '焊材名称',
          prop: 'name',
          type: 'text',
          labelWidth: '130px',
          use: ['table', 'add', 'view', 'edit', 'search'],
          rules: [
            { required: true, message: '请输入焊材名称', trigger: 'change' }
          ],
        },
        {
          label: '材料类型',
          prop: 'type',
          type: 'text',
          labelWidth: '130px',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          label: '焊材直径',
          prop: 'diameter',
          type: 'number',
          labelWidth: '130px',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          label: '数量',
          prop: 'quantity',
          type: 'number',
          labelWidth: '130px',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          label: '品牌',
          prop: 'brand',
          type: 'text',
          labelWidth: '130px',
          use: ['table', 'add', 'view', 'edit', 'search']
        },
        {
          prop: 'spaceId',
          defaultValue: this.$store.state.project.spaceId,
          use: ['add', 'edit']
        }
      )
      arr.push({ label: '操作', type: 'handle', use: ['table'], handle: ['view', 'edit', 'delete'], tableWidth: 300 })
      return arr
    },
    filters() {
      return [{
        field: 'spaceId',
        operator: 'EQUALS',
        value: this.$store.state.project.spaceId
      }]
    }
  },
  methods: {
  }
}
</script>

<style>

</style>
